<template>
  <div class="table">
    <div class="container">
      <div class="handle-box" style="text-align: center;color: red;font-weight: bold;font-size: 20px">
        每台设备每日最多能够收到{{this.List[0].smsDayMax}}条短信验证
        <!--<el-button type="primary" size="mini" @click="delAll">批量删除</el-button>-->
        <!--<el-input v-model="select_word" size="mini" placeholder="查询管理员（id,用户名，昵称）" class="handle-input"></el-input>-->
        <!--<el-button type="primary" size="mini" @click="centerDialogVisible = true">添加管理员</el-button>-->
      </div>
    </div>
    <el-table class="el-table_p"   ref="multipleTable" border :data="List">
      <!--<el-table-column type="selection" ></el-table-column>-->
      <el-table-column prop="id" label="配置id" align="center"></el-table-column>
      <el-table-column prop="smsDayMax" label="短信次数(单位：次)" align="center"></el-table-column>

      <el-table-column label="操作" align="center" >
        <template slot-scope="scope">
          <el-button size="mini" type="primary" @click="handleEdit(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>


    <el-dialog title="修改短信次数" :visible.sync="editVisible" width="400px" center>
      <el-form :model="form" ref="form" label-width="80px" :rules="rules">
        <el-form-item prop="smsDayMax" label="短信次数" size="mini">
          <el-input v-model="form.smsDayMax" placeholder="短信次数"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer">
                <el-button size="mini" @click="editVisible = false">取消</el-button>
                <el-button size="mini" @click="editSave" type="primary">确定</el-button>
            </span>
    </el-dialog>


  </div>
</template>

<script>
  import {getSet, updateSet} from '../../api/public/api';
  import {mixin} from '../../../static/js/index';
  export default {
    mixins: [mixin],
    data() {
      return {
        level: 0,
        List: [{
          id:"",//
          smsDayMax: "",

        },],

        form: {
          id:"",//编辑框
          smsDayMax: "",

        },

        centerDialogVisible: false, //添加弹窗是否显示
        editVisible: false,         //编辑弹窗是否显示
        delVisible: false,          //删除弹窗是否显示
        delMangeArr:[],


        rules: {
          smsDayMax: [
            {required: true, message: '请输入用户名', trigger: 'blur'}
          ]
        }
      }
    },


    created() {
      let data = {}
      this.getData(data);
      this.level = localStorage.getItem('level')
    },
    methods: {
      updateData() {
        let data = {}
        this.getData(data);
      },
      //查询
      getData(data) {
        getSet(data).then(res => {
          if (res.data.code == 0) {
            this.List=[]
            this.List.push(res.data.data)
          }


        })
      },

      //弹出编辑页面
      handleEdit(row) {

        this.editVisible = true;
        this.form = row

      },
      //保存编辑页面修改的数据
      editSave() {
        this.$refs['form'].validate(valid => {
          if (valid) {
            let params = this.form

            updateSet(params).then(res => {
              if (res.data.code == 0) {
                this.editVisible = false;
                this.notify("修改成功", "success");
                this.updateData()
              } else {
                this.notify("修改失败", "error");
              }
            })
              .catch(err => {
                console.log(err);
              });

          }
        })

      },


    }
  }
</script>

<style scoped>
  .handle-box {
    margin-bottom: 20px;
  }
  .center{

  }
</style>
